package com.dbexplore.web;

import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
import java.util.List;
import java.util.Collections;
import java.util.ArrayList;
import java.sql.SQLException;

import com.dbexplore.db.structure.Table;
import com.dbexplore.db.DatabaseGateway;
import com.dbexplore.service.TableService;


public class IndexController implements Controller {

    public TableService getTableManager() {
        return tableManager;
    }

    public void setTableManager(TableService tableManager) {
        this.tableManager = tableManager;
    }

    private TableService tableManager;

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {

        ModelAndView view = new ModelAndView("index.jsp");
        view.addObject("tableList", tableManager.getAllTables());

        return view;
      }


    
}
